﻿using System.Collections.Generic;
using KillBill.Presentarion.Common.Printing;
using KillBill.Presentarion.Common.Printing.Reports;
using KillBill.Presentation.Common;
using KillBill.Presentation.Shell.ProductsServiceReference;

namespace KillBill.Presentation.Shell
{
    public class Reports
    {
        private ProductsServiceClient _productsServiceClient;
        public Reports()
        {
            _productsServiceClient = new ProductsServiceClient();
        }
        public void PriceReport()
        {
            Report printer = new Report();

            var products = _productsServiceClient.GetProductList(Context.SessionID);
            var Table = new List<object[]>();
            foreach (var a in products.Products)
            {
                Table.Add(new object[] { a.ProductID, a.Name, a.LastPrice, a.Stock });

            }
            printer._companyData = new List<string>();
            printer._companyName = "";
            printer.AllPagesHeader = true;
            printer.Footer = "";
            printer.ColumnsFormat = new List<ColumnFormat>();
            printer.ColumnsFormat.Add(new ColumnFormat("Código", 10, Formater.position.right));
            printer.ColumnsFormat.Add(new ColumnFormat("Descripción", 20));
            printer.ColumnsFormat.Add(new ColumnFormat("Precio", 2, 10));
            printer.ColumnsFormat.Add(new ColumnFormat("Stok", 0, 10));

            printer.DataTable = Table;
            printer.ReportName = "Lista de Precios";
            printer.showPreView();

        }
    }
}
